// pages/library/popularCategories/popularCategories.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        header: '',
        taget1_content: [],
        taget2_content: [],
        taget3_content: [],
        taget4_content: [],
        taget5_content: [],
        taget6_content: [],
        taget7_content: [],
        taget8_content: [],
        taget9_content: [],
        taget10_content: [],
        taget11_content: [],
        taget12_content: [],
        taget13_content: [],
        taget14_content: [],
        taget15_content: [],
        taget16_content: [],
          
          
    },
    getTagetContent: function (taget) {
        var that = this;
        wx.request({
          url: 'http://127.0.0.1:5000/aps/' + taget,
    
          success: function (res) {
            console.log('Response:', res);
            that.setData({
              [taget + '_content']: res.data ,// 成功获取内容后将其保存在对应标签的 content 属性中
            //   currentTagContent: res.data
            });
          },
          fail: function (err) {
            console.error('Failed to fetch data:', err); // 检查请求失败的情况
        }
        });
      },
    onLoad: function (options) {
        const name = options.name;
        var that = this;
        if (name === '爱国') {
            that.getTagetContent('taget1');
            that.setData({
            header: '爱国',
            content: that.data.taget1_content
          })
        } else if (name === '友情') {
            that.setData({
            header: '友情',
            content: '友情内容'
          })
        } else if (name === '爱情') {
            that.setData({
             headedr:'爱情',
             content:''
         })
        }else if (name === '思乡') {
            that.setData({
                header:'',
                content:''
            })
           }else if (name === '田园') {
            that.setData({
                header:'',
                content:''
            })
           }else if (name === '抒怀') {
            that.setData({
                header:'',
                content:''
            })
           }else if (name === '怀古') {
            that.setData({
                header:'',
                content:''
            })
           }else if (name === '赠别') {
            that.setData({
                header:'',
                content:''
            })
           }else if (name === '民生') {
            that.setData({
                header:'',
                content:''
            })
           }else if (name === '边塞') {
            that.setData({
                header:'',
                content:''
            })
           }else if (name === '离别') {
            that.setData({
                header:'',
                content:''
            })
           }else if (name === '思念') {
            that.setData({
                header:'',
                content:''
            })
           }else if (name === '感恩') {
            that.setData({
                header:'感恩',
                content:''
            })
           }else if (name === '伤感') {
            that.setData({
                header:'',
                content:''
            })
           }else if (name === '悼亡') {
            that.setData({
                header:'',
                content:''
            })
           }else if (name === '孤独') {
            that.setData({
                header:'',
                content:''
            })
           }
      },


    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})